/*
**------------------------------------
** Created By: Feroz Noushad
** Created On: May 17 2012 
** Desc : Ajax Function Called From XMSA Web
**------------------------------------
*/
// Ajax Common Object Intializer
function AjaxInitializer(){
 var contentType = "application/x-www-form-urlencoded; CHARSET=UTF-8";
 try{
	  CommonAjax = new XMLHttpRequest();
	 }catch(trymicrosoft){
	  try{
		   CommonAjax = new ActiveXObject("Msxml2.XMLHTTP");
		  }catch(othermicrosoft){
		   try{
				CommonAjax = new ActiveXObject("Microsoft.XMLHTTP");
			   }catch(failed){
				CommonAjax = false;
			   }
		  }
	 }
 if(!CommonAjax){
  alert("Cannot Create XMLHttpRequest !"); 
 }
}
//Create All Controls in form to a Query String

function getQueryString(formName) {
		 var objForm = document.getElementById(formName);
		 var componentArray = new Array();
			 for (var i=0 ; i < objForm.elements.length; i++) {
			  var formElements = encodeURIComponent(objForm.elements[i].name);
			  formElements += "=";
				  if(objForm.elements[i].checked){
				   formElements += "1?";
				  }else {
				   formElements += encodeURIComponent(objForm.elements[i].value);
				  }
			  componentArray.push(formElements);
			 }
		 return componentArray.join("&");
	}
//Call for Common Help
function showHelp(JSPName,formName){
		AjaxInitializer();
		var CurTime = new Date().getTime()
		var Url = JSPName+".jsp?formName="+formName+"&today="+CurTime;
		CommonAjax.open('GET',Url, false);
		CommonAjax.send(null);
		if(CommonAjax.status == 200){				
			document.getElementById("commonHelp").innerHTML="";	
			document.getElementById("commonHelp").innerHTML=CommonAjax.responseText;
			disCombo(formName,"I")
			document.getElementById("commonHelp").style.visibility="visible";
			
		}
	}
//Close Common Help
function closeHelp(formName){
	document.getElementById("commonHelp").style.visibility="hidden";
	disCombo(formName,"A")
	}

//Call for Common Help with No Combo Disable
function showHelpNoSelect(JSPName,formName){
		AjaxInitializer();
		var CurTime = new Date().getTime()
		var Url = JSPName+".jsp?formName="+formName+"&today="+CurTime;
		CommonAjax.open('GET',Url, false);
		CommonAjax.send(null);
		if(CommonAjax.status == 200){				
			document.getElementById("commonHelp").innerHTML="";	
			document.getElementById("commonHelp").innerHTML=CommonAjax.responseText;
			document.getElementById("commonHelp").style.visibility="visible";
			
		}
	}	
//Close Common Help with No Select Enable
function closeHelpNoSelect(formName){
	document.getElementById("commonHelp").style.visibility="hidden";
	}	

function disCombo(formName,bool){
	 var objForm = document.getElementById(formName);
			 for ( i=0 ; i < objForm.elements.length; i++) {
				 if(objForm.elements[i].type=="select-one"){
				  if(bool=="I"){
					  objForm.elements[i].style.visibility="hidden"
				  }else{
				  	  objForm.elements[i].style.visibility="visible"
				  }
				 }			 
			 }
		}	